// 0 引入 用来发送请求的 方法 一定要把路径补全
import { request } from "../../request/index.js";
const app = getApp()
Page({
  data: {
    // 轮播图数组
    swiperList: [
      'cloud://ultraman-8g0hcrf7c8afe553.756c-ultraman-8g0hcrf7c8afe553-1306160066/Ultraman/swiper1.jpeg',
      'cloud://ultraman-8g0hcrf7c8afe553.756c-ultraman-8g0hcrf7c8afe553-1306160066/Ultraman/swiper2.jpeg',
      'cloud://ultraman-8g0hcrf7c8afe553.756c-ultraman-8g0hcrf7c8afe553-1306160066/Ultraman/swiper3.jpeg',
      'cloud://ultraman-8g0hcrf7c8afe553.756c-ultraman-8g0hcrf7c8afe553-1306160066/Ultraman/swiper4.jpeg',
      'cloud://ultraman-8g0hcrf7c8afe553.756c-ultraman-8g0hcrf7c8afe553-1306160066/Ultraman/swiper5.jpeg'
    ],
    // 导航 数组
    catesList:[],
    // 楼层数据
    floorList: app.globalData.goodsList
  },
  addShopCar: function(e){
    var that = this
    var index = e.currentTarget.dataset.index
    var floorList = that.data.floorList
    var num = floorList[index].num
    var shopCar = app.globalData.shopCar
    wx.showToast({
      title: '添加购物车成功',
      icon: 'success',
      duration: 2000
    })
    if(num == 0){
      floorList[index].num++
      shopCar.push(floorList[index])
    }else{
      shopCar.forEach((item) => {
        if(item.name == floorList[index].name){
          item.num++
        }
      });
    }
  },
  // 页面开始加载 就会触发
  onLoad: function (options) {
      
  },
})
